<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>键盘事件</title>
  <script src="../js/vue.js"></script>
</head>
<body>
<div id="root">
  姓：<input type="text" v-model="firstName"><br>
  名：<input type="text" v-model="lastName"><br>
  全名：<span>{{fullName}}</span>
</div>
<script>
  new Vue({
    el: "#root",
    data() {
      return {
        firstName: "张",
        lastName:"三",
      }
    },
    computed:{
      fullName:{
       get(){
         return this.firstName+'-'+this.lastName;
       },
       set(value){
         const arr = value.split('-')
         this.firstName=arr[0]
         this.lastName=arr[1]
       }
      }
    }
  })
</script>
</body>
</html>
